package com.example.arithmeticleetcode.leetcode.jan;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2021-01-11 09:15
 **/
public class Demo08 {

    public static void main(String[] args) {
        totalMoney(4);
    }

    public static int totalMoney(int n) {
        int remain = n / 7;
        int mod = n % 7;
        int start = 1;
        int end = 7;
        int sum = 0;
        while (remain > 0) {
            sum += ((start++ + end++) >> 1) * 7;
            remain --;
        }
        while (mod > 0) {
            sum += start++;
            mod--;
        }
        return sum;
    }
}
